package unimelb.distSystems.project2;

/*
 * Lim Ching Lih, 308721
 * Yu Xia, 351025
 * Carlos Vasconcelos, 193554
 */

import java.util.Arrays;
import unimelb.distSystems.communications.CORBA.*;
import org.omg.CORBA.*;

/*
 * COBRA client service helper 
 */
public class ClientServiceImpl extends ClientServicePOA{
    private ORB orb;
    private GameClient client;

    public void setORB(ORB orb_val) {
        orb = orb_val;
    }

    public ClientServiceImpl(GameClient c) {
        super();
        client = c;
    }

    public void updatePlayers(ServicePlayer[] players){
        if(client.game.getCurrent_screen() instanceof MatchRoomScreen){
            client.game.getMatchroom_gui().display_players(Arrays.asList(players));
        }
    }

    public void updateChat(String[] chat){
        if(client.game.getCurrent_screen() instanceof MatchRoomScreen){
            client.game.getMatchroom_gui().display_messages(Arrays.asList(chat));
        }
    }

    public void marks(ServicePlayer[] players){
            client.game.getMatchroom_gui().launchRacingSession(players);
    }

    public void go(){
            client.game.getGame().go();
    }

    public void takeAction(ServiceAction action){
        client.game.getGame().onRemoteAction(action);
    }

    public void endGame(){
        client.game.getGame().setWinner();
    }
}
